package com.xatl.simulated.controller;

import com.xatl.simulated.client.MqttPublishClient;
import com.xatl.simulated.constant.MqttPropertiesUtils;
import com.xatl.simulated.response.MyDeviceData;
import com.xatl.simulated.util.JsonUtil;
import com.xatl.simulated.util.NumberUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * @Author ufo
 * @Description TODO
 * @Date 2021/1/13 15:22
 * @Version 1.0
 */



@RestController
@RequestMapping("/mqtt")
public class realController {
    @Autowired
    private MqttPropertiesUtils mqttPropertiesUtils;

    @GetMapping("/sendd")
    public String sendd(){
        HashMap<String, List<MyDeviceData>> HashMap = new HashMap<>();


        HashMap.put("1000", NumberUtil.random());
        HashMap.put("1001",NumberUtil.random());
        HashMap.put("1007",NumberUtil.random());
        HashMap.put("1018",NumberUtil.random());

//
        String s = JsonUtil.objectToJson(HashMap);
        //发布方法
        MqttPublishClient.publish("DOWN/TEST/CONTROL",mqttPropertiesUtils.getQos(),s);
        return "ok";
    }



}
